<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="java.net.InetAddress"%>
<!DOCTYPE html>
<html>
<head>
<!-- String Name=(String)session.getAttribute("userName");
if(Name==null){
	response.sendRedirect("shopLogin4.jsp");
}
-->
<%!Vector v=new Vector();
	ServletContext application;
	synchronized void sendMessage(String s){
	application=getServletContext();
	v.add(s);
	application.setAttribute("Message", v);
	
}
%>	
<link rel="stylesheet" href="css/zerogrid.css">
<link rel="stylesheet" href="css/style3.css">
<!-- messages样式 -->
<link href="css/mb-comingsoon-iceberg.css" rel="stylesheet" />

<meta charset="UTF-8">
<title>留言区</title>
</head>
<body>
<h1><a href="main.jsp">返回首页</a></h1>
<%!String nickname,Mtitle,Mcontent,MIP,Mtime;String IP;int count=0,count1=2; %>
	<%
		String name1 = (String) session.getAttribute("userName");
		String email = (String) session.getAttribute("email");
	%>
	<header>
	<div class="wrap-header">
	<div class="main-header">
	<div class="zerogrid">
	<h1>欢迎来到救援员管理系统</h1>
	<h1>留言区</h1>
	<div class="counter">
	<div class="centered text-center" id="myCounter">
	<div class="counter-group" id="myCounter">
	<div class="counter-block">
	<div class="counter days">
	
	<div class="number show n1 tens">3</div>
	<div class="number show n1 units">8</div>
	</div>
	<div class="counter-caption">The</div>
	</div>
	<div class="counter-block">
	<div class="counter hours">
	<div class="number show n1 tens">0</div>
	<div class="number show n1 units">6</div>
	</div>
	<div class="counter-caption">number</div>
	</div>
	<div class="counter-block">
	<div class="counter minutes">
	<div class="number show n1 tens">2</div>
	<div class="number show n1 units">5</div>
	</div>
	<div class="counter-caption">of</div>
	</div>
	<div class="counter-block">
	<div class="counter seconds">
	<div class="number show n1 tens"><%=count1 %></div>
	<div class="number show n1 units"><%=count %></div>
	</div>
	<div class="counter-caption">messages</div>
	</div>
	</div>
	</div>
	</div>
	</div>
	</div>
	</div>
	</header>

	<section class="content-box boxstyle-1 box-1">
	<div class="zerogrid">
	<div class="row wrap-box">
	<div class="col-1-2">
	<div class="col-3-5">
	<div class="wrap-col">
	<h1>他 <br>说：</h1>
	<p>根据有关应急预案，利用对突发公共事故的研判结果，通过应急平台对有关法律法规、政策、安全技术要求、危化品处置手册、现场处置方案以及处理类似事件的案例等进行智能检索和分析，并咨询专家意见，提供应对突发公共事故的辅助决策方案。</p>
	</div>
	</div>
	<div class="col-2-5">
	<div class="wrap-col">
	<img src="images/work.jpg">
	</div>
	</div>
	</div>
	<div class="col-1-2">
	<div class="col-3-5 fix-right">
	<div class="wrap-col">
	<h1>她 <br>：说</h1>
	<p>通过信息化、网络化手段实现重点设备信息查询、区域重点部位三维模型展示、重大危险源事故后果模拟、基于GIS进行高级业务分析等功能，满足突发事故状态下政府安全生产应急救援辅助决策及日常应急准备和巡查的需要。</p>
	</div>
	</div>
	<div class="col-2-5">
	<div class="wrap-col">
	<img src="images/work4.jpg">
	</div>
	</div>
	</div>
	</div>
	</div>
	</section>

	<section class="content-box boxstyle-2 box-2">
	<div class="zerogrid" style="width: 100%;">
	<div class="row wrap-box">
	<div class="header">
	<div class="wrapper">
	<h2 class="color-yellow">More Messages</h2>
	<hr class="line">
	<div class="intro">您也來留言吧！</div>
	</div>
	</div>
	</div>
	</div>
	</section>

	<div class="headimage">
		<img src="images/head2.jpg">
	</div>

	<form action="submit3.jsp" method="post">
	
		<div class="mestitle">
			标题：<input type="text" id="mestitle1" name="title">
		</div>
		<div id="mestitle2">
			用户名：<%out.println(name1);%>
		</div>

		<table class="mestitle3">
			<tr>
				<th>内容：</th>
				<th><textarea id="textarea" name="content"></textarea></th>
			</tr>
			<tr>
				<th colspan="2"><input type="submit" value="发表" id="button1">
					<input type="reset" value="重置" id="button2"></th>
			</tr>
		</table>
		<div id="mestitle4">
			邮箱：<%out.println(email); %>
		</div>
	</form>
	
	<%count++;
	if(count>9){
		count=0;
		count1++;
	} %>
<%

String content=request.getParameter("content");
String title=request.getParameter("title");
/*session.setAttribute("content", content);
session.setAttribute("title", title);*/
//IP=request.getHeader("x-forwarded-for");
//IP=InetAddress.getLocalHost().toString();
		/*java.util.Enumeration enema=application.getInitParameterNames();
		while(enema.hasMoreElements()){
			String name=(String)enema.nextElement();
			String value=application.getInitParameter(name);
			IP=value;
		}
		*/
		//获取本机(或者服务器ip地址)
		//InetAddress ia = InetAddress.getLocalHost();
		 
		String IP = InetAddress.getLocalHost().toString();

String name=(String)session.getAttribute("userName");
String time=new Date().toString();

 if(content!=null&&title!=null){
	
	 String s="#"+name+"#"+title+"#"+content+"#"+IP+"#"+time+"#";
	 sendMessage(s);
	Vector v1=(Vector)application.getAttribute("Message");
	
		for (int i = 0; i < v1.size(); i++) {
			
			String message = (String) v1.elementAt(i);
			StringTokenizer fenxi = new StringTokenizer(message, "#");
			while(fenxi.hasMoreElements()){
			int number = fenxi.countTokens();
			for (int k = 0; k < number; k++){
				if(k==0){
					nickname=fenxi.nextToken();
				}
				if(k==1){
					Mtitle=fenxi.nextToken();
				}
				if(k==2){
					Mcontent=fenxi.nextToken();
				}
				if(k==3){
					MIP=fenxi.nextToken();
				}
				if(k==4){
					Mtime=fenxi.nextToken();
				}
			}
			}%>
			
	
	<div class="mestitle7">
	<%
	out.print("<table>");
	out.print("<tr>");
	out.print("<th colspan=4>"+"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" +"</th>");
	out.print("</tr>");
	out.print("<tr>");
		out.print("<th colspan=1>" + "用户昵称:" + "</th>");
		out.print("<th colspan=3 align=left>" + nickname + "</th>");
	out.print("</tr>");
	
	out.print("<tr>");
	out.print("<th colspan=1>" + "留言标题:" + "</th>");
	out.print("<th colspan=3 align=left>" + Mtitle + "</th>");
	out.print("</tr>");
	
	out.print("<tr>");
	out.print("<th colspan=1>" + "留言内容:" + "</th>");
	out.print("<th colspan=3 align=left>" + Mcontent + "</th>");
	out.print("</tr>");
	
	out.print("<tr>");
	out.print("<th colspan=1>" + "用户IP:" + "</th>");
	out.print("<th colspan=1 align=left>" + MIP + "</th>");
	out.print("<th colspan=1 >" + "留言时间:" + "</th>");
	out.print("<th colspan=1 align=left>" + Mtime + "</th>");
	out.print("</tr>");
	out.print("</table>");
	}%>
		</div>

<%}%>

</body>
</html>